package cn.kimming.rpc.autoconfigure;

import cn.kimming.rpc.common.constant.LoadBalance;
import cn.kimming.rpc.common.constant.ProxyWay;
import cn.kimming.rpc.common.constant.RpcConstant;
import cn.kimming.rpc.common.constant.SerializationWay;
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties("my.rpc")
public class MyRpcProperties {

	private String application;

    private final Server server = new Server();
    private final Zk zk = new Zk();
    private final Client client = new Client();

    public Server getServer() {
        return server;
    }

    public Zk getZk() {
        return zk;
    }

	public String getApplication() {
		return application;
	}

	public void setApplication(String application) {
		this.application = application;
	}

    public Client getClient() {
        return client;
    }

    public static class Server {
        private int port = RpcConstant.MY_RPC_SERVER_PORT_DEFAULT_VALUE;
        private boolean enabled = false;

        public int getPort() {
            return port;
        }

        public void setPort(int port) {
            this.port = port;
        }

        public boolean isEnabled() {
            return enabled;
        }

        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }

    }

    public static class Zk {
        private String url = RpcConstant.MY_RPC_ZK_URL_DEFAULT_VALUE;
        private int timeout = RpcConstant.MY_RPC_ZK_TIMEOUT_DEFAULT_VALUE;

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public int getTimeout() {
            return timeout;
        }

        public void setTimeout(int timeout) {
            this.timeout = timeout;
        }
    }

    public static class Client {
        private int timeout = RpcConstant.MY_RPC_ZK_TIMEOUT_DEFAULT_VALUE;
        private ProxyWay proxy = RpcConstant.MY_RPC_CLIENT_PROXY_WAY_DEFAULT_VALUE;
        private SerializationWay serialization = RpcConstant.MY_RPC_SERIALIZATION_WAY_DEFAULT_VALUE;
        private LoadBalance loadBalance = RpcConstant.MY_RPC_LOAD_BALANCE_DEFAULT_VALUE;

        public int getTimeout() {
            return timeout;
        }

        public void setTimeout(int timeout) {
            this.timeout = timeout;
        }

        public ProxyWay getProxy() {
            return proxy;
        }

        public void setProxy(ProxyWay proxy) {
            this.proxy = proxy;
        }

        public SerializationWay getSerialization() {
            return serialization;
        }

        public void setSerialization(SerializationWay serialization) {
            this.serialization = serialization;
        }

        public LoadBalance getLoadBalance() {
            return loadBalance;
        }

        public void setLoadBalance(LoadBalance loadBalance) {
            this.loadBalance = loadBalance;
        }
    }
}
